<template>
    <div>
        <a-modal
            title="列入计划"
            :visible="visible"
            :confirm-loading="confirmLoading"
            @ok="handleOk"
            @cancel="visible = false"
            :width="785"
        >
            <div class="initiateRegistrationComp-box">
                <a-form-model
                    :id="randomId"
                    class="form-model-big-box form-model-big-box1"
                    ref="initiateRegistrationCompForm"
                    :model="currentRow"
                    :rules="rules"
                    layout="inline"
                >
                    <!-- <a-form-model-item ref="fjcbmrwmc" label="审评报名任务名称" prop="fjcbmrwmc" class="form-item-flex-1">
                        <a-textarea 
                            v-model="currentRow.fjcbmrwmc"
                            :autosize="{ minRows: 2, maxRows: 10000 }"
                            placeholder="请输入审评报名任务名称"
                        ></a-textarea>
                    </a-form-model-item> -->
                    <!-- <a-form-model-item label="审评员类型" class="form-item-flex-1">
                        <div style="line-height: 52px;">
                            <span v-for="(item,index) in vxeOptionsArr" :key="index">{{ item.itemValue }}{{ vxeOptionsArr.length-1 !== index?'，':'' }}</span>
                        </div>
                    </a-form-model-item> -->
                    
                    <a-form-model-item label="审评日期" required prop="fbmksrqArr">
                        <div style="display: flex;align-items: center;">
                            <a-range-picker v-model="currentRow.fbmksrqArr" style="width: 100%;" />
                            <div style="width: 195px;">
                                <span v-if="currentRow.fbmksrqArr[0]" style="width: 75px;">（{{ moment(currentRow.fbmksrqArr[0]).format('dddd') }}</span>
                                <span v-if="currentRow.fbmksrqArr[1]" style="width: 95px;">&nbsp;&nbsp;至&nbsp;&nbsp;{{ moment(currentRow.fbmksrqArr[1]).format('dddd') }}）</span>
                            </div>
                        </div>
                    </a-form-model-item>
                    <!-- <a-form-model-item label="报名结束日期" required prop="fbmjsrq">
                        <a-date-picker
                            v-model="currentRow.fbmjsrq"
                            style="min-width: 184px;"
                            show-time
                            type="date"
                            placeholder="请选择时间"
                        />
                    </a-form-model-item> -->
                    <a-form-model-item label="审评地点" prop="fjcdd" class="form-item-flex-1">
                        <a-input placeholder="请输入审评地点" v-model:value="currentRow.fjcdd"/>
                    </a-form-model-item>
                    <a-form-model-item label="审评要求" class="form-item-flex-1">
                        <a-textarea 
                            v-model="currentRow.fjcyq"
                            :autosize="{ minRows: 2, maxRows: 10000 }"
                            placeholder="请输入审评要求"
                        ></a-textarea>
                    </a-form-model-item>
                    <!-- <a-form-model-item label="组长人数" prop="fzzrs">
                        <a-input-number v-model:value="currentRow.fzzrs" :min="0" :precision="0" placeholder="组长人数" />
                    </a-form-model-item>
                    <a-form-model-item label="组员人数" prop="fzyrs">
                        <a-input-number v-model:value="currentRow.fzyrs" :min="0" :precision="0" placeholder="组员人数"/>
                    </a-form-model-item>
                    <a-form-model-item label="预备审评员人数" prop="fybrs">
                        <a-input-number v-model:value="currentRow.fybrs" :min="0" :precision="0" placeholder="预备审评员人数"/>
                    </a-form-model-item> -->
                </a-form-model>
            </div>
        </a-modal>
    </div>
</template>
<script>
import { ybmjhaddBmjhmx, ocalityPostAction, ybmjhupdateBmjh,ybmjhlrbmjhBySqsx, } from './service/index'
import moment from 'moment'
export default {
    components:{

    },
    props:{

    },
    data(){
        return{
            moment:moment,
            visible:false,
            confirmLoading:false,
            randomId:'formModel'+new Date().getTime(),
            currentRow:{},
            currentData:{},
            rules: {
                fjcbmrwmc: [{ required: true, message: '请输入审评报名任务名称', trigger: 'blur' }],
                fbmksrqArr: [{ type: 'array', required: true, message: '请选择审评日期', trigger: 'change' }],
                fjcdd: [{ required: true, message: '请输入审评地点', trigger: 'blur' }],
            },
            vxeOptionsArr:[],
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        getData(row,val){
            this.currentData = row
            this.currentRow = {
                fbmksrqArr:row.fcykssj?[moment(row.fcykssj),moment(row.fcyjssj)]:[],
                fjcdd:val.fjcdd,
                fjcyq:val.fjcyq,
                sqsxid:row.sqsxid,
                // fzzrs:0,
                // fzyrs:0,
                // fybrs:0,
            }
            this.confirmLoading = false
            // 检查员登记类别
            ocalityPostAction({dictName:'检查员登记类别'}).then(res=>{
                //console.log('字典的res',res)
                if(res.code == 200){
                    if(res.result.length){
                        this.vxeOptionsArr = res.result
                    }
                    
                }
            })
        },
        handleOk(){
            this.$refs.initiateRegistrationCompForm.validate(valid => {
                if (valid) {
                    // if(this.currentRow.fzzrs || this.currentRow.fzyrs || this.currentRow.fybrs){
                        let data = {
                            ...this.currentRow,
                            fcykssj:moment(this.currentRow.fbmksrqArr[0]).format('YYYY-MM-DD'),
                            fcyjssj:moment(this.currentRow.fbmksrqArr[1]).format('YYYY-MM-DD'),
                            fbmksrqArr:''
                        }
                        if(this.currentRow.id){
                            ybmjhupdateBmjh(data).then(res=>{
                                if(res.code == 200){
                                    this.$message.success(res.message)
                                    this.$emit('addInspectionTaskSuccess')
                                    this.visible = false
                                }else{
                                    this.$message.warning(res.message)
                                }
                            })
                        }else{
                            ybmjhlrbmjhBySqsx(data).then(res=>{
                                if(res.code == 200){
                                    this.$message.success(res.message)
                                    this.$emit('addInspectionTaskSuccess')
                                    this.visible = false
                                }else{
                                    this.$message.warning(res.message)
                                }
                            })
                        }
                        
                    // }else{
                    //     this.$message.warning('请输入人数')
                    // }
                    
                } else {
                    //console.log('error submit!!');
                    return false;
                }
            });
            
        },
    }
}
</script>
<style lang="less">
.initiateRegistrationComp-box{
    display: flex;
    flex-wrap: wrap;
    textarea.ant-input{
        margin-top: 4px;
    }
    .ant-form-item{
        // display: flex;
        // align-items: center;
        .ant-form-item-label{
            font-size: 18px;
            font-weight: 600;
            width: 145px;
            font-family:simHei;
            background: #e6f7ff;
        }
        .ant-form-item-control-wrapper{
            vertical-align: middle;
        }
    }
    .toolbox-form-item{
        width: 50%;
        // padding: 3px;
    }
    .ant-form-item-with-help{
        margin-bottom: 10px;
    }
    .form-model-big-box{
        .form-item-flex-1{
            display: flex;
            .ant-form-item-control-wrapper{
                flex: 1;
                
            }
        }
        .ant-form-item-control-wrapper{
            font-family:仿宋_GB2312 !important;
            
            .ant-checkbox-group{
                height: 40px;
                line-height: 40px;
            }
        }
    }
    .form-model-big-box1{
        .ant-form-item-label{
            
            margin: 4px 3px;
            label{
                padding-left: 3px;
                
            }
            
        }
    }
    .ant-form-inline .ant-form-item > .ant-form-item-label{
        vertical-align: middle !important;
    }
    
}
</style>